package com.hnichr.ping.common;

import org.apache.commons.lang3.StringUtils;

public interface DictEnum {

    enum SEND_RESULT {

        OK("1","成功"), FAILED("0","失败");
        private String code;

        private String name;

        SEND_RESULT(String code, String name){
            this.code = code;
            this.name = name;
        }

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

    enum MESSAGE_TYPE {
        SMS("sms","短信"), EMAIL("email","电子邮件");
        private String code;

        private String name;

        MESSAGE_TYPE(String code, String name){
            this.code = code;
            this.name = name;
        }

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public static boolean exists(String code){
            for(DictEnum.MESSAGE_TYPE messageType:DictEnum.MESSAGE_TYPE.values()){
                if(StringUtils.equals(code,messageType.getCode())){
                    return true;
                }
            }
            return false;
        }
    }

    enum STATUS {
        OPEN("1","启用"), CLOSED("0","禁用");
        private String code;

        private String name;

        STATUS(String code, String name){
            this.code = code;
            this.name = name;
        }

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public static boolean exists(String code){
            for(DictEnum.MESSAGE_TYPE messageType:DictEnum.MESSAGE_TYPE.values()){
                if(StringUtils.equals(code,messageType.getCode())){
                    return true;
                }
            }
            return false;
        }
    }

}
